/**
 * 
 */
package com.tagit.speech;

import java.util.HashMap;

/** A singleton holding the current active Sessions.
 * Based on {@link org.speechapi.SpeechSessionManager}
 * @author Mohamed Ali
 */
public class SpeechSessionManager {
	
	/** The singleton */
	private static SpeechSessionManager instance = null;
	
	/** A map for the active sessions */
	private static HashMap<String, SpeechSession> sessions;
	
	
	private SpeechSessionManager() {
		sessions = new HashMap<String, SpeechSession>();
	}
	
	public static SpeechSessionManager getInstance() {
		if(instance == null)
			instance = new SpeechSessionManager();		
		return instance;
	}
	
	public void newSession(SpeechSession session) {
		sessions.put(session.getId(), session);
	}
	
	public SpeechSession getSession(String id) {
		return sessions.get(id);
	}
	
	public SpeechSession removeSession(String id){
		return sessions.remove(id);
	}
	
	public SpeechSession removeSession(SpeechSession session) {
		return sessions.remove(session);
	}
}
